{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>引导页</h5>
        </div>
        <div class="ibox-content">
            {if($data)}
            <img style="width: 1000px" class="img" src="{$data.src}">
            {/if}
            <!-- End Example Pagination -->
            <input type="hidden" class="id" value="{$data.id}">
            
            <button style="display: block;" type="button" class="layui-btn" id="test1">
                <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
            <!--<button style="display: block" class="layui-btn layui-btn-warm layui-btn-radius edit">更换图片</button>-->

        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

{include file="public/footer" /}
<script>
        $('.edit').click(function () {

        });
        layui.use('upload', function(){
            var upload = layui.upload;

            //执行实例
            var uploadInst = upload.render({
                elem: '#test1' //绑定元素
                ,url: '/admin/upload/upload' //上传接口
                ,done: function(res){
                    //上传完毕回调
                    if(res.code == 200){
                        edit_ajax(res.data.src)
                        // $('#src').attr('value',res.data.src);
                        // $('#img').attr('src',res.data.src);
                        // $('#img').css('display','');
                        // layer.msg('上传成功', {icon: 1});
                    }else {
                        layer.msg(res.msg, {icon: 2});
                    }

                }
                ,error: function(){
                    //请求异常回调
                }
            });
        });
        function edit_ajax(src) {
            var id = $('.id').val();
            $.post('/admin/bp/edit_src',{src:src,id:id},function (data) {
                if(data.code == 200){
                    $('.img').attr('src',src);
                }else {
                    layer.msg(res.msg, {icon: 2});
                }

            },'json');
        }
</script>


</body>
</html>